package cn.shengongying.api.vo;

import cn.shengongying.model.UserPositionApplyRecord;
import cn.shengongying.model.WorkerList;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import java.util.List;
import java.util.stream.Collectors;

/**
 * author: RXK
 * date: 2022/1/10 星期一
 * desc:
 */
@Getter
@Setter
public class UserInterviewVo extends UserResumeVo {

    private static final long serialVersionUID = 7321920331519801685L;


    @ApiModelProperty(value = "是否邀请面试(0:否;1:是)")
    private Integer status;


    @ApiModelProperty(value = "是否接收面试邀请(0:否;1:是)")
    private Integer receiveInterviewInvite;

    @ApiModelProperty(value = "是否接收回答邀请(0:否;1:是)")
    private Integer receiveAnswerInvite;

    public static List<UserInterviewVo> list(List<UserPositionApplyRecord> recordList, List<WorkerList> lists) {
        return recordList.stream()
                .map(userPositionApplyRecord -> {
                    UserInterviewVo vo = new UserInterviewVo();
                    vo.setId(userPositionApplyRecord.getId());
                    vo.setUserId(userPositionApplyRecord.getUserId());
                    lists.stream()
                            .filter(workerList -> workerList.getId()
                                    .compareTo(userPositionApplyRecord.getUserId()) == 0)
                            .findFirst()
                            .ifPresent(workerList -> {
                                vo.setHeadPicture(workerList.getImg());
                                vo.setName(workerList.getName());
                                vo.setPositionName(workerList.getJob());
                                vo.setPlace(workerList.getPlace());
                                vo.setAddress(workerList.getAddress());
                                vo.setExperience(workerList.getExperience());
                                vo.setReceiveInterviewInvite(workerList.getReceiveInterviewInvite());
                                vo.setReceiveAnswerInvite(workerList.getReceiveAnswerInvite());
                            });
                    vo.setStatus(userPositionApplyRecord.getStatus());
                    return vo;
                })
                .collect(Collectors.toList());
    }
}
